package com.jpa.web.service.impl;

import com.jpa.web.model.Employee;
import com.jpa.web.repository.EmployeeCrudRepository;
import com.jpa.web.repository.EmployeeRepository;
import com.jpa.web.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * Created by BKWJA on 2018/10/27.
 * 事务通常写在serviceimpl 实现类中
 */
@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    public EmployeeRepository employeeRepository;

    /**
     * 更新操作
     * @param id
     * @param name
     */
    @Override
    @Transactional
    public void update(Integer id,String name){
        employeeRepository.update(id,name);
    }

    @Override
    @Transactional
    public void deleteByEmpid(Integer id) {
        employeeRepository.deleteByEmpid(id);
    }

    @Override
    @Transactional
    public void save(Employee employee) {
        employeeRepository.save(employee);
    }


}
